package com.rsscollector.model.vo;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;

@Entity
@Table(name = "RSS_PROVIDER")
public class RssProvider implements Serializable {

    private Long id;
    private String name;
    private Collection<RssSource> rssSources = new HashSet<RssSource>();

    // No-arg constructor
    public RssProvider() { /* empty */ }

    public RssProvider(String name) {
        this.name = name;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "RSS_PROVIDER_ID")
    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "NAME", nullable = false, length = 512)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "rssProvider")
    public Collection<RssSource> getRssSources() {
        return this.rssSources;
    }

    public void setRssSources(Collection<RssSource> rssSources) {
        this.rssSources = rssSources;
    }
}
